<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of InCaretime_Validator
 *
 * @author johnnypark
 */
class Fkb_Validate_InCaretime extends Zend_Validate_Abstract
{

    const NOT_IN_CARETIME = 'NOT_IN_CARETIME';

    protected $_messageTemplates = array(
	self::NOT_IN_CARETIME => "'%value%' liegt nicht innerhalb der möglichen Betreuungszeit",
    );

    public function isValid($dateAsString)
    {
	try
	{
	    $date = new Zend_Date($dateAsString);
	    $this->_setValue($date->toString(Zend_Date::TIME_SHORT));

	    $modelStatusflag = new Model_Statusflag();
	    if ($modelStatusflag->inCaretime($date))
	    {
		return true;
	    } else
	    {
		$this->_error(self::NOT_IN_CARETIME);
		return false;
	    }
	} catch (Exception $exception)
	{
	    return false;
	}
    }

}

?>
